package xyz.yuzegod.megawalls.classes.normal.spider;

import xyz.yuzegod.megawalls.classes.Classes;
import xyz.yuzegod.megawalls.classes.Skill;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.stats.KitStatsContainer;
import xyz.yuzegod.megawalls.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class SecondSkill extends Skill
{
    public SecondSkill(final Classes classes) {
        super("毒液之击", classes);
    }
    
    @Override
    public int maxedLevel() {
        return 3;
    }
    
    @Override
    public double getAttribute(final int level) {
        switch (level) {
            case 1: {
                return 0.1;
            }
            case 2: {
                return 0.15;
            }
            case 3: {
                return 0.2;
            }
            default: {
                return 0.1;
            }
        }
    }
    
    @Override
    public List<String> getInfo(final int level) {
        final List<String> lore = new ArrayList<String>();
        if (level == 1) {
            lore.add(" §8▪ §7受到摔落伤害,每损失一颗心的生命值,");
            lore.add("   §7获得§a" + StringUtils.percent(this.getAttribute(level)) + "§7的伤害加成(最多4次)");
            return lore;
        }
        lore.add(" §8▪ §7受到摔落伤害,每损失一颗心的生命值,");
        lore.add("   §7获得§8" + StringUtils.percent(this.getAttribute(level - 1)) + " ➜ §a" + StringUtils.percent(this.getAttribute(level)) + "§7的伤害加成(最多4次)");
        return lore;
    }
    
    @Override
    public void upgrade(final GamePlayer gamePlayer) {
        final KitStatsContainer kitStats = gamePlayer.getPlayerStats().getKitStats(this.getClasses());
        kitStats.addSkill2Level();
    }
    
    @Override
    public int getPlayerLevel(final GamePlayer gamePlayer) {
        return gamePlayer.getPlayerStats().getKitStats(this.getClasses()).getSkill2Level();
    }
    
    @Override
    public boolean use(final GamePlayer gamePlayer, final KitStatsContainer kitStats) {
        return true;
    }
    
    @Override
    public String getSkillTip(final GamePlayer gamePlayer) {
        if (Spider.skill2.getOrDefault(gamePlayer, 0) == 0) {
            return null;
        }
        return this.getClasses().getNameColor() + "§l" + this.getName() + " §c§l" + StringUtils.percent(this.getAttribute(this.getPlayerLevel(gamePlayer))) + " " + Spider.skill2.get(gamePlayer) + "次攻击";
    }
}
